// UserDefinedFunction.js

function ScriptFn()
{
	var self = new UserDefinedFunction("Jon's Average");
	self.m_Value = 0;
	self.m_Count = 0;
	self.clone = function()
	{
		return new ScriptFn();
	}
	self.update = function(data) 
	{
		if (data!=null)
		{
			this.m_Value = this.m_Value + data.doubleValue();
			++this.m_Count;
		}
	}
	self.getResult = function()
	{
		return this.m_Value / this.m_Count;
	}
	self.reset = function()
	{
		this.m_Value = 0; 
		this.m_Count = 0;
	}
	return new JavaAdapter(Packages.com.elixirtech.data2["function"].Function, self);
}

/*

// This function access in report by adding these to the 
// script.

importClass(Packages.com.elixirtech.data2["function"].FunctionFactory);
FunctionFactory.addUserFunction(new ScriptFn());

*/
